package com.hilon.foundation.para;

import lombok.Data;

import java.util.Date;

@Data
public class ConditionPara {
    private Date dateBegin;
    private Date dateEnd;
    private String categoryType;
    private String categoryTypeDetail;
    private String categoryName;
    private String personCreate;
    private String personCheck;
    private String no;
    private String batchNo;
    private String batchNoOriginal;
    private String customer;
    private String supplierCustomer;
    private String categoryCheck = "全部"; //已审核、未审核、全部
    private String categoryPerform = "全部"; //已生产、未生产、全部
    private String additionCondition = ""; //传入的其他and条件
    private String warehouseNo;
    private String contractNo;
    private String steelGrade;
    private String specification;
    private Double quantity;
    private Double quantityMin = (double) -100000000;
    private Double quantityMax = (double) 1000000;
    private String receivingUnit;
    private String noOpenPlan;
    private String contractNoFrom;
    private String contractNoTransfer;
    private String customerFrom;
    private String customerTransfer;
    private String noProcessPerform;
    private String statusComplete = "尚未生产";
    private String batchNoUsedPerform;
    private String batchNoPlan;
    private String name;
    private String worker;
    private String personWorkDaily;
    private String position;
    private String workshop;
    private String person;
    private String nameReceipt;
    private String categoryTypeReceipt;
    private String approveNo;
    private String approveItem;
    private String workType;
    private String noID;
    private String companyLabor;
    private String nameLabor;
    private String specificationPerforms;
    private String specificationUsed;
    private String categoryOpenPlan;
    private String subSystemCustomer;

    private String leaderDirect;
    private String categoryDemand;
    private String categoryContract;
    private String categoryAddress;
    private String categoryRecruitment;
    private String categoryWorkTime;
    private String leaderDepart;
    private String leaderHuman;
    private String leaderManager;







    public static void formatData(ConditionPara c) {
        if (c.getCategoryType().isEmpty() || c.getCategoryType().equals("全部")) c.setCategoryType("%");
        else c.setCategoryType("%" + c.getCategoryType() + "%");
        if (c.getCategoryTypeDetail().isEmpty() || c.getCategoryTypeDetail().equals("全部"))
            c.setCategoryTypeDetail("%");
        else c.setCategoryTypeDetail("%" + c.getCategoryTypeDetail() + "%");
        if (c.getCategoryName().isEmpty() || c.getCategoryName().equals("全部")) c.setCategoryName("%");
        else c.setCategoryName("%" + c.getCategoryName() + "%");
        if (c.getPersonCreate().isEmpty()) c.setPersonCreate("%");
        else c.setPersonCreate("%" + c.getPersonCreate() + "%");
        if (c.getPersonCheck().isEmpty()) c.setPersonCheck("%");
        else c.setPersonCheck("%" + c.getPersonCheck() + "%");
        if (c.getNo().isEmpty()) c.setNo("%");
        else c.setNo("%" + c.getNo() + "%");
        if (c.getBatchNo().isEmpty()) c.setBatchNo("%");
        else c.setBatchNo("%" + c.getBatchNo().trim() + "%");
        if (c.getCustomer().isEmpty()) c.setCustomer("%");
        else c.setCustomer("%" + c.getCustomer() + "%");
        if (c.getSupplierCustomer().isEmpty()) c.setSupplierCustomer("%");
        else c.setSupplierCustomer("%" + c.getSupplierCustomer() + "%");
        if (c.getBatchNoOriginal().isEmpty()) c.setBatchNoOriginal("%");
        else c.setBatchNoOriginal("%" + c.getBatchNoOriginal() + "%");
        if (c.getWarehouseNo().isEmpty()) c.setWarehouseNo("%");
        else c.setWarehouseNo("%" + c.getWarehouseNo() + "%");
        if (c.getContractNo().isEmpty()) c.setContractNo("%");
        else c.setContractNo("%" + c.getContractNo() + "%");
        if (c.getSteelGrade().isEmpty()) c.setSteelGrade("%");
        else c.setSteelGrade("%" + c.getSteelGrade() + "%");
        if (c.getSpecification().isEmpty()) c.setSpecification("%");
        else c.setSpecification("%" + c.getSpecification() + "%");
        if (c.getQuantity() == null || c.getQuantity() == (double) 0){
            c.setQuantity((double) 0);
        } else {
            c.setQuantityMin(c.getQuantity());
            c.setQuantityMax(c.getQuantity());
        };
        if (c.getReceivingUnit().isEmpty()) c.setReceivingUnit("%");
        else c.setReceivingUnit("%" + c.getReceivingUnit() + "%");
        if (c.getNoOpenPlan().isEmpty()) c.setNoOpenPlan("%");
        else c.setNoOpenPlan("%" + c.getNoOpenPlan() + "%");
        if (c.getContractNoFrom().isEmpty()) c.setContractNoFrom("%");
        else c.setContractNoFrom("%" + c.getContractNoFrom() + "%");
        if (c.getContractNoTransfer().isEmpty()) c.setContractNoTransfer("%");
        else c.setContractNoTransfer("%" + c.getContractNoTransfer() + "%");
        if (c.getCustomerFrom().isEmpty()) c.setCustomerFrom("%");
        else c.setCustomerFrom("%" + c.getCustomerFrom() + "%");
        if (c.getCustomerTransfer().isEmpty()) c.setCustomerTransfer("%");
        else c.setCustomerTransfer("%" + c.getCustomerTransfer() + "%");
        if (c.getNoProcessPerform().isEmpty()) c.setNoProcessPerform("%");
        else c.setNoProcessPerform("%" + c.getNoProcessPerform() + "%");
        if(c.getStatusComplete().equals("全部")) c.setStatusComplete("%");
        if (c.getBatchNoUsedPerform().isEmpty()) c.setBatchNoUsedPerform("%");
        else c.setBatchNoUsedPerform("%" + c.getBatchNoUsedPerform() + "%");
        if(c.getBatchNoPlan().isEmpty()) c.setBatchNoPlan("%");
        else c.setBatchNoPlan("%" + c.getBatchNoPlan() + "%");
        if(c.getName().isEmpty()) c.setName("%");
        else c.setName("%" + c.getName() + "%");

        if(c.getWorker().isEmpty()) c.setWorker("%");
        else c.setWorker("%" + c.getWorker() + "%");
        if(c.getPersonWorkDaily().isEmpty()) c.setPersonWorkDaily("%");
        else c.setPersonWorkDaily("%" + c.getPersonWorkDaily() + "%");
        if(c.getPosition().isEmpty()) c.setPosition("%");
        else c.setPosition("%" + c.getPosition() + "%");
        if(c.getWorkshop().isEmpty()) c.setWorkshop("%");
        else c.setWorkshop("%" + c.getWorkshop() + "%");

        if (c.getPerson().isEmpty()) c.setPerson("%");
        else c.setPerson("%" + c.getPerson() + "%");
        if(c.getNameReceipt().isEmpty()) c.setNameReceipt("%");
        else c.setNameReceipt("%" + c.getNameReceipt() + "%");
        if(c.getCategoryTypeReceipt().isEmpty()) c.setCategoryTypeReceipt("%");
        else c.setCategoryTypeReceipt("%" + c.getCategoryTypeReceipt() + "%");
        if(c.getApproveNo().isEmpty()) c.setApproveNo("%");
        else c.setApproveNo("%" + c.getApproveNo() + "%");
        if(c.getApproveItem().isEmpty()) c.setApproveItem("%");
        else c.setApproveItem("%" + c.getApproveItem() + "%");

        if (c.getWorkType().isEmpty()) c.setWorkType("%");
        else c.setWorkType("%" + c.getWorkType() + "%");
        if(c.getNoID().isEmpty()) c.setNoID("%");
        else c.setNoID("%" + c.getNoID() + "%");

        if(c.getCompanyLabor().isEmpty()) c.setCompanyLabor("%");
        else c.setCompanyLabor("%" + c.getCompanyLabor() + "%");
        if(c.getNameLabor().isEmpty()) c.setNameLabor("%");
        else c.setNameLabor("%" + c.getNameLabor() + "%");

        if(c.getSpecificationUsed().isEmpty()) c.setSpecificationUsed("%");
        else c.setSpecificationUsed("%" + c.getNameLabor() + "%");
        if(c.getSpecificationPerforms().isEmpty()) c.setSpecificationPerforms("%");
        else c.setNameLabor("%" + c.getSpecificationPerforms() + "%");

        if(c.getCategoryOpenPlan().isEmpty()) c.setCategoryOpenPlan("%");
        else c.setCategoryOpenPlan("%" + c.getCategoryOpenPlan() + "%");

        if(c.getLeaderDirect().isEmpty()) c.setLeaderDirect("%");
        else c.setLeaderDirect("%" + c.getLeaderDirect() + "%");

        if(c.getCategoryDemand().isEmpty()) c.setCategoryDemand("%");
        else c.setCategoryDemand("%" + c.getCategoryDemand() + "%");

        if(c.getCategoryContract().isEmpty()) c.setCategoryContract("%");
        else c.setCategoryContract("%" + c.getCategoryContract() + "%");

        if(c.getCategoryAddress().isEmpty()) c.setCategoryAddress("%");
        else c.setCategoryAddress("%" + c.getCategoryAddress() + "%");

        if(c.getCategoryRecruitment().isEmpty()) c.setCategoryRecruitment("%");
        else c.setCategoryRecruitment("%" + c.getCategoryRecruitment() + "%");

        if(c.getCategoryWorkTime().isEmpty()) c.setCategoryWorkTime("%");
        else c.setCategoryWorkTime("%" + c.getCategoryWorkTime() + "%");

        if(c.getLeaderDepart().isEmpty()) c.setLeaderDepart("%");
        else c.setLeaderDepart("%" + c.getLeaderDepart() + "%");

        if(c.getLeaderHuman().isEmpty()) c.setLeaderHuman("%");
        else c.setLeaderHuman("%" + c.getLeaderHuman() + "%");

        if(c.getLeaderManager().isEmpty()) c.setLeaderManager("%");
        else c.setLeaderManager("%" + c.getLeaderManager() + "%");
    }

    public static void formatPara(ConditionPara c) {
        if (c.getBatchNo().isEmpty()) c.setBatchNo("%");
        else c.setBatchNo("%" + c.getBatchNo().trim() + "%");
        if (c.getCustomer().isEmpty()) c.setCustomer("%");
        else c.setCustomer("%" + c.getCustomer().trim() + "%");
        if (c.getSupplierCustomer().isEmpty()) c.setSupplierCustomer("%");
        else c.setSupplierCustomer("%" + c.getSupplierCustomer().trim() + "%");
        if (c.getContractNo().isEmpty()) c.setContractNo("%");
        else c.setContractNo("%" + c.getContractNo() + "%");
        if (c.getSpecification().isEmpty()) c.setSpecification("%");
        else c.setSpecification("%" + c.getSpecification() + "%");
        if (c.getBatchNoOriginal().isEmpty()) c.setBatchNoOriginal("%");
        else c.setBatchNoOriginal("%" + c.getBatchNoOriginal() + "%");
        if (c.getCategoryName().isEmpty() ) c.setCategoryName("%");
        else c.setCategoryName("%" + c.getCategoryName() + "%");
        if (c.getCategoryType().isEmpty()) c.setCategoryType("%");
        else c.setCategoryType("%" + c.getCategoryType() + "%");
        if (c.getSubSystemCustomer().isEmpty()) c.setSubSystemCustomer("%");
        else c.setSubSystemCustomer("%" + c.getSubSystemCustomer() + "%");
    }
}
